package com.insigma.business.common.service.impl;

import com.insigma.business.common.service.DfsService;
import com.insigma.business.common.utils.MinIoUtil;
import com.insigma.framework.exception.AppException;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class DfsServiceImpl implements DfsService {
    @Override
    public String upload(MultipartFile file, String bucketName, String modelName) {
        try {
            return MinIoUtil.upload(file,bucketName,modelName);
        } catch (Exception e) {
            throw new AppException(e.getMessage());
        }
    }

    @Override
    public String uploadRetainChName(MultipartFile file, String bucketName, String modelName) {
        try {
            return MinIoUtil.uploadRetainChName(file,bucketName,modelName);
        } catch (Exception e) {
            throw new AppException(e.getMessage());
        }
    }

    @Override
    public String preViewFile(String filePath,String endpoint) {
        try {
            return MinIoUtil.preViewFile(filePath,endpoint);
        } catch (Exception e) {
            throw new AppException(e.getMessage());
        }
    }
}
